# STAT 202 Project
# Decision Tree
# Author: Fatih Sunor
#####################################################

# Read data
rm(list = ls(all = TRUE));
train <- read.csv("training.csv",header=TRUE);
relevance <- as.factor(train[[13]]);


error<-NULL;
for(i in 1:15){
decisionTree<-rpart(relevance~.,feature,control=rpart.control(minsplit=0,
					minbucket=0,cp=-1,
					maxcompete=0,maxsurrogate=0, usesurrogate=0,
					xval=0,maxdepth=i));
	
p<-predict(decisionTree,feature,type="class");

# Test
error[i]<-sum(relevance!=p)/length(relevance);
}
